<template>
	<view>
		<u-navbar title="" titleColor="#FFFFFF" backIconColor="#FFFFFF" :borderBottom="false" :background="background">
		</u-navbar>
		<view class="top">
			<view class="title">
				首次蜜贝兑换
			</view>
			<view class="icon">
				兑换多送的多
			</view>
		</view>
		<view class="content">
			<image src="../static/d1.png" class="title"></image>
			<view class="cont">
				<u-row gutter="10">
					<u-col :span="4" v-for="(item,index) in list" :key="index">
						<view @click="active=index" :class="active==index?'active list':'list'">
							<view class="up">
								兑换
							</view>
							<view class="number">
								{{parseInt(item.kmb_number)}} <text>蜜贝</text>
							</view>
							<view class="down">
								赠送 <text>{{parseInt(item.give_kmb_number)}} </text> 蜜贝
							</view>
						</view>
					</u-col>
				</u-row>
			</view>
			<view class="text">
				<image src="../static/d2.png" mode=""></image> 蜂盈为迎接新用户，特此推出<text>蜜贝兑换优惠活动</text>兑换越多送的越多 您则可获得
			</view>
			<u-button class="b1" type="primary" @click="show=true">确认兑换</u-button>
		</view>
		<u-popup v-model="show" close-icon-pos="top-left" :closeable="true" borderRadius="10" mode="bottom">
			<view class="harvest">
				<view class="_view">
					<view class="title">
						兑换确认
					</view>
					<view class="text">
						当前活动每人仅有一次选择机会 请慎重选择兑换蜜贝数量
					</view>
					<view class="text">
						<text>选择之后操作不可逆，是否确认兑换</text>
					</view>
				</view>
				<view class="button">
					<button type="default" class="b1" @click="show=false">重新选择</button>
					<button type="default" class="b2" @click="applyKmb">确认兑换</button>
				</view>
				<view class="popup_top"></view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	var than;
	export default {
		data() {
			return {
				background: {
					background: '#69B7FF'
				},
				active: 0,
				list: [],
				show: false,
			}
		},
		onLoad(option) {
			than = this;
			than.post("api/Novice_goods/kmbList", null, function(data) {
				than.list = data;
			})
		},
		methods: {
			applyKmb() {
				than.post("api/Novice_goods/applyKmb", {
					id: than.list[than.active].id
				}, function(data) {
					uni.navigateTo({
						url: '/pages/htmlB/farm/v-index?zhujian_id=' + data
					})
				})
			}
		}
	}
</script>

<style lang="less">
	.harvest {
		text-align: center;


		.popup_top {
			height: 30rpx;
		}

		.img {
			overflow: hidden;
			padding: 0 55rpx;
			margin-top: 44rpx;

			.left {
				float: left;

				image {
					width: 27rpx;
					height: 27rpx;
				}
			}

			.right {
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #666666;

				text {
					color: #004FFF;
				}
			}

		}

		._view {
			background: #FFFFFF;
			margin: 0 30rpx;
			padding-bottom: 1rpx;


			.title {
				margin-bottom: 80rpx;
				height: 111rpx;
				line-height: 111rpx;
				text-align: center;
				border-bottom: 2rpx solid #F6F6F6;
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
			}

			.text {
				padding: 0 80rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #666666;

				text {
					color: #FB683D;
				}
			}
		}


		.button {
			padding: 28rpx 0;
			display: flex;

			.b1 {
				width: 245rpx;
				height: 74rpx;
				border: 1rpx solid #FB683D;
				background: #FFFFFF;
				border-radius: 20rpx;
				font-size: 28rpx;
				r font-family: PingFang SC;
				font-weight: 500;
				color: #FB683D;
			}

			.b2 {
				width: 245rpx;
				height: 74rpx;
				background: #FB683D;
				border-radius: 20rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
			}
		}


	}

	.top {
		position: fixed;
		width: 750rpx;
		height: 530rpx;
		background: linear-gradient(0deg, #D4ECFF, #69B7FF);
		text-align: center;
		z-index: 1;

		.title {
			text-align: center;
			font-size: 48rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
		}

		.icon {
			margin-top: 47rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			padding: 0 26rpx;
			display: inline-flex;
			height: 43rpx;
			background: #58ACF9;
			border-radius: 22rpx;
		}
	}

	.content {
		position: relative;
		z-index: 3;
		background: #FFFFFF;
		margin: 350rpx 36rpx 0;
		border-radius: 20rpx;
		padding-bottom: 53rpx;
		text-align: center;

		.title {
			margin-top: -150rpx;
			width: 258rpx;
			height: 292rpx;
		}

		.b1 {
			width: 562rpx;
			height: 74rpx;
			background: #4092FE;
			border-radius: 20rpx;
		}

		.cont {
			margin: 0 17rpx;
		}

		.active {
			border: 2rpx solid #FADA9D !important;

			.number {
				color: #FF2D01 !important;
			}

			.down {
				background: #FADA9D !important;

				text {
					color: #FF2D01 !important;
				}
			}
		}

		.list {
			text-align: center;
			width: 208rpx;
			height: 254rpx;
			background: #FFFFFF;
			border: 2rpx solid #EAEAEA;
			border-radius: 10rpx;
			position: relative;

			.up {
				padding-top: 39rpx;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
			}

			.number {
				font-size: 60rpx;
				font-family: DIN;
				font-weight: bold;
				color: #666666;

				text {
					font-size: 24rpx;
				}
			}

			.down {
				position: absolute;
				width: 100%;
				bottom: 0;
				display: flex;
				align-items: center;
				justify-content: center;
				height: 58rpx;

				text {
					margin-top: -5rpx;
					font-size: 36rpx;
					font-weight: bold;
				}

				font-size: 24rpx;
				background: #EAEAEA;
				border-radius: 0rpx 0rpx 10rpx 10rpx;
			}
		}

		.text {
			padding: 0 23rpx;
			margin-top: 84rpx;
			margin-bottom: 61rpx;

			image {
				width: 27rpx;
				height: 27rpx;
				margin-right: 5rpx;
			}

			text {
				color: #FF5B00;
			}

			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #72808F;
			text-align: left;
		}
	}

	page {
		background: #F8F8F8;
	}
</style>
